package com.jrx.anytxn.param.job.investor.investorLimit.step;

import com.jrx.anytxn.param.entity.PrInvestorLimit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * 出资方额度更新  - processor
 *
 * @author liuyang
 * @date 2020-06-01
 */
@Service
public class InvestorLimitProcessor implements ItemProcessor<PrInvestorLimit, PrInvestorLimit> {

    private static final Logger logger = LoggerFactory.getLogger(InvestorLimitProcessor.class);

    @Override
    public PrInvestorLimit process(PrInvestorLimit investorLimit) {
        PrInvestorLimit updateInvestorLimit=new PrInvestorLimit();
        updateInvestorLimit.setId(investorLimit.getId());
        updateInvestorLimit.setTenantId(investorLimit.getTenantId());
        updateInvestorLimit.setOrganizationId(investorLimit.getOrganizationId());
        updateInvestorLimit.setDailyUsedLimit(BigDecimal.ZERO); // 日已用额度清零
        updateInvestorLimit.setDailyAvailLimit(investorLimit.getDailyMaxLimit()); // 日可用额度设置为最大额度
        return updateInvestorLimit;
    }
}
